(: Ex1 :)
<Countries_of_the_Danube>
{
let $x := tokenize(doc("/db/mondial-europe")/mondial/river[name='Donau']/@country, "\s")
for $c in doc("/db/mondial-europe")/mondial/country
where $c/@car_code = $x
return $c/name
}
</Countries_of_the_Danube>

(: Ex 2 :)
<Big_countries_with_no_Danube>
{
let $x := tokenize(doc("/db/mondial-europe")/mondial/river[name='Donau']/@country, "\s")
for $c in doc("/db/mondial-europe")/mondial/country[population >= 30000000]
where $c/@car_code != $x
return <country car_code="{$c/@car_code}">{$c/name}{$c/population}</country>
}
</Big_countries_with_no_Danube>

(: Ex3 :)

<Southernmost_city_in_continental_France>
{
  let $f := doc('/db/mondial-europe')/mondial/country[@car_code='F']/province[name!='Corse']/city
  for $c in $f[latitude =min($f/latitude)]
     return <city> {$c/name}
                   {$c/latitude}
            </city>
}
</Southernmost_city_in_continental_France>

(: Ex4 :)
let $countries := doc('/db/mondial-europe')/mondial/country[@car_code='D']/border/@country
let $pop := doc('/db/mondial-europe')/mondial/country[@car_code=$countries]/population
return <Info_on_countries_which_border_Germany
country_count="{count($countries)}"
pop_sum="{sum($pop)}"
pop_avg="{avg($pop)}"
/>


